//this is the header file for the locker functions

#ifndef __LOCKER_H__
#define __LOCKER_H__

#include <stdlib.h>
#include <nfc/nfc.h>
#include "internal.h"

//#define KEY_SIZE 16
#define LOCKER_COUNT 2

int total_num_lockers;

//typedef int bool;
//#define true 1
//#define false 0

struct locker {
    int lockerNum;
	bool locked;
	char* key;
	nfc_device *reader;
	nfc_context *context;
    struct locker_pins *LockerPins;
    bool active;
};

struct locker_pins {
	int pin_strike_lock;
	int pin_led_green;
	int pin_led_red;
};

void init_locker (struct locker *l, int locker_num, const nfc_connstring device, nfc_context *context);

void init_lockers (struct locker* l, int locker_count, nfc_connstring devices[], nfc_context *context);

int compare_key(char* key, struct locker *l);

void lock_locker(struct locker *l, char *key);

void unlock_locker(struct locker *l);

void erase_key(struct locker *l);

void change_locker_state (struct locker *l);

void blink_red_led(struct locker *l, int blink_rate, int cycles); // blink_rate is in ms

void free_locker_mem(struct locker *l);

void free_lockers_mem(struct locker *lockers, int locker_count);
#endif
